package com.cms.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cms.common.StringUtils;
import com.cms.constant.ReportConstant;
import com.cms.dao.CmsJdbcBaseDao;
import com.cms.model.PageModel;
import com.cms.service.ReportService; 


@Service
public class ReportServiceImpl implements ReportService {

	@Autowired
	protected CmsJdbcBaseDao cmsDao;
	
	@Override
	public List<Map> getReportResult(String repCode, Map<String, Object> param)throws Exception 
	{
		return (List<Map>)cmsDao.getRepResult(repCode, param);
	}

	@Override
	public PageModel pagingReportResult(String repCode, Map<String, Object> param) throws Exception 
	{
		return this.cmsDao.pagingResult(repCode, param);
	}

	@Override
	public Map<String, Object> getRepConfig(String repCode) throws Exception 
	{
		return cmsDao.getRepCode(repCode);
	}

	@Override
	public Map<String, Object> querySingleResult(String repCode,
			Map<String, Object> param) throws Exception {
		return cmsDao.querySingleResult(repCode, param);
	}
	
	@Override
	public String queryCmsSeq(String catalog) {
		Map<String,Object>queryParam = new HashMap<String, Object>();
		queryParam.put(ReportConstant.QUERY_CMS_PARAM, catalog);
		Map<String,Object>result= this.cmsDao.getSingleResultByOrgSql(ReportConstant.QUERY_CMS_SEQ, queryParam);
		return StringUtils.obj2String(result.get(ReportConstant.CMS_ORDER_KEY));
	}

	@Override
	public String querySystemConfig(String config) {
		Map<String,Object>queryParam = new HashMap<String, Object>();
		queryParam.put(ReportConstant.QUERY_SYS_PARAM, config);
		Map<String,Object>result= this.cmsDao.getSingleResultByOrgSql(ReportConstant.QUERY_SYS_CONFIG, queryParam);
		return StringUtils.obj2String(result.get(ReportConstant.CMS_SYS_KEY));
	}
}
